Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@gasket/engine
Advanced tools
Plugin engine for Gasket. This is used internally by the Gasket CLI.
A plugin is a module in the gasket
ecosystem that provides a unit of
functionality. Some plugins are core to the overall application, others
optional.
For documentation on plugins, refer to the plugin guide.
A preset is simply a package with Gasket plugins dependencies. This allows common plugins to be grouped together, and loaded by way of a preset.
For documentation on presets, refer to the preset guide.
The GasketAPI
object passed to hook functions has the following members:
The Gasket configuration object, typically derived from gasket.config.js
.
The exec
method enables a plugin to introduce new lifecycle events. When
calling exec
, await the Promise
it returns to wait for the hooks of other
plugins to finish. If the lifecycle event is for producing data, the Promise
will contain an Array
of the hook data stored in the order the hooks were
executed.
The execSync
method is like exec
, only all hooks must execute synchronously.
The synchronous result is an Array of the hook return values. Using synchronous
methods limits flexibility, so it's encouraged to use async methods whenever
possible.
The execMap
method is just like exec
, only the Promise result is an object
map with each key being the name of the plugin and each value the result from
the hook. Only the plugins that hooked the event will have keys present in the
map.
The execSyncSync
method is like execMap
, only all hooks must execute
synchronously.
The execApply
method execution is ordered like exec
, but you must invoke the
handler yourself with explicit arguments. These arguments can be dynamic based
on the plugin itself. e.g.:
await gasket.execApply('someEvent', async (plugin, handler) => {
// Creating the "Contextual thing" can be sync or async. async params are
// fully supported with this pattern if necessary.
const arg = await Contextual.thingWith(plugin);
return handler(arg); // The gasket parameter is automatically applied
});
The execApplySync
method is like execApply
, only all hooks must execute
synchronously.
The execWaterfall
method is like exec
, only it allows you to have each hook
execute sequentially, with each result being passed as the first argument to the
next hook. It's like an asynchronous version of Array.prototype.reduce
. The
final result is returned in the resulting Promise.
The execWaterfallSync
method is like execWaterfall
, only each hook must
execute synchronously. The final value is returned synchronously from this call.
Using synchronous methods limits flexibility, so it's encouraged to use async
methods whenever possible.
Injects additional lifecycle hooks at runtime. Takes a single object parameter with the following properties:
Property | Required? | Description |
---|---|---|
event | Yes | The name of the event to hook. This is the same thing as the property name in the hooks of a plugin definition. |
handler | Yes | The function to call when the event occurs. The function should take the same form as the hooks callbacks in a plugin definition. |
timing | No | Ordering constraints for when the hook will execute. Same as the optional timing property in plugin hooks. |
pluginName | No | Defaults to an auto-generated name. Only supply this if you need other hooks to be able to order themselves relative to this hook via timing constraints. Important note: only one hook per event is allowed per plugin name, so if your plugin is injecting dynamic hooks, be sure that the names are dynamic enough to avoid conflicts. |
When a preset extends another preset, the version of the plugin registered can
be overridden if the parent preset sets a different dependency version.
Additionally, if an app specifies a plugin directly in the gasket.config using
add
, the version determined by the app will instead be registered.
This package is used internally by the Gasket CLI, so you probably do not need to use this directly. If you do, instantiate an engine by passing in plugins.
import GasketEngine from '@gasket/engine';
import MyPlugin from './my-plugin';
const engine = new GasketEngine([MyPlugin]);
The plugin engine will parse the configuration, import the configured plugins, and register their hooks. The engine instance is the same GasketAPI object passed to hook handlers.
The Gasket engine uses the debug
package to trace the plugin lifecycle.
If you set the DEBUG
environment variable to gasket:engine
you'll see
additional output in stderr
indicating when things are invoked.
FAQs
Plugin engine for gasket
The npm package @gasket/engine receives a total of 104 weekly downloads. As such, @gasket/engine popularity was classified as not popular.
We found that @gasket/engine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.